package com.appoint.web.controller.buss;

import com.appoint.buss.domain.EpiparaAtacSeq;
import com.appoint.buss.domain.req.EpiparaAtacSeqReqVO;
import com.appoint.buss.domain.vo.EpiparaAtacSeqRespVO;
import com.appoint.buss.service.IEpiparaAtacSeqService;
import com.appoint.common.annotation.Anonymous;
import com.appoint.common.annotation.Log;
import com.appoint.common.core.controller.BaseController;
import com.appoint.common.core.domain.AjaxResult;
import com.appoint.common.core.page.TableDataInfo;
import com.appoint.common.enums.BusinessType;
import com.appoint.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * epipara_atac_seqController
 *
 * @author appoint
 * @date 2023-01-15
 */
@RestController
@RequestMapping("/buss/atacSeq")
public class EpiparaAtacSeqController extends BaseController
{
    @Autowired
    private IEpiparaAtacSeqService EpiparaAtacSeqService;

    /**
     * 查询epipara_atac_seq列表
     */
    @PreAuthorize("@ss.hasPermi('buss:atacSeq:list')")
    @GetMapping("/list")
    public TableDataInfo list(EpiparaAtacSeq EpiparaAtacSeq)
    {
        startPage();
        List<EpiparaAtacSeq> list = EpiparaAtacSeqService.selectEpiparaAtacSeqList(EpiparaAtacSeq);
        return getDataTable(list);
    }

    /**
     * 导出epipara_atac_seq列表
     */
    @PreAuthorize("@ss.hasPermi('buss:atacSeq:export')")
    @Log(title = "epipara_atac_seq", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EpiparaAtacSeq EpiparaAtacSeq)
    {
        List<EpiparaAtacSeq> list = EpiparaAtacSeqService.selectEpiparaAtacSeqList(EpiparaAtacSeq);
        ExcelUtil<EpiparaAtacSeq> util = new ExcelUtil<>(EpiparaAtacSeq.class);
        util.exportExcel(response, list, "epipara_atac_seq数据");
    }

    /**
     * 获取epipara_atac_seq详细信息
     */
    @PreAuthorize("@ss.hasPermi('buss:atacSeq:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(EpiparaAtacSeqService.selectEpiparaAtacSeqById(id));
    }

    /**
     * 新增epipara_atac_seq
     */
    @PreAuthorize("@ss.hasPermi('buss:atacSeq:add')")
    @Log(title = "epipara_atac_seq", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EpiparaAtacSeq EpiparaAtacSeq)
    {
        return toAjax(EpiparaAtacSeqService.insertEpiparaAtacSeq(EpiparaAtacSeq));
    }

    /**
     * 修改epipara_atac_seq
     */
    @PreAuthorize("@ss.hasPermi('buss:atacSeq:edit')")
    @Log(title = "epipara_atac_seq", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EpiparaAtacSeq EpiparaAtacSeq)
    {
        return toAjax(EpiparaAtacSeqService.updateEpiparaAtacSeq(EpiparaAtacSeq));
    }

    /**
     * 删除epipara_atac_seq
     */
    @PreAuthorize("@ss.hasPermi('buss:atacSeq:remove')")
    @Log(title = "epipara_atac_seq", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(EpiparaAtacSeqService.deleteEpiparaAtacSeqByIds(ids));
    }

    @Log(title = "信息导入", businessType = BusinessType.IMPORT)
    @PreAuthorize("@ss.hasPermi('buss:atacSeq:import')")
    @PostMapping("/importData")
    public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception
    {
        ExcelUtil<EpiparaAtacSeq> util = new ExcelUtil<>(EpiparaAtacSeq.class);
        List<EpiparaAtacSeq> list = util.importExcel(file.getInputStream());
        String operName = getUsername();
        String message = EpiparaAtacSeqService.importUser(list, updateSupport, operName);
        return AjaxResult.success(message);
    }

    /**
     * 查询epipara_atac_seq列表
     */
    @Anonymous
    @GetMapping("/list2")
    public TableDataInfo list2(EpiparaAtacSeqReqVO reqVO)
    {
        startPage();
        List<EpiparaAtacSeqRespVO> list = EpiparaAtacSeqService.list2(reqVO);
        return getDataTable(list);
    }

    /**
     * 导出epipara_atac_seq列表
     */
    @Anonymous
    @PostMapping("/list2Export")
    public void list2Export(HttpServletResponse response, EpiparaAtacSeqReqVO EpiparaAtacSeq)
    {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        List<EpiparaAtacSeqRespVO> list = EpiparaAtacSeqService.list2(EpiparaAtacSeq);
        ExcelUtil<EpiparaAtacSeqRespVO> util = new ExcelUtil<>(EpiparaAtacSeqRespVO.class);
        util.exportExcel(response, list, sdf.format(new Date()));
    }
}
